package com.abou.mvc.controller.customer;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttributes;
import com.abou.model.common.product.search.SearchProductsRequest;
import com.abou.mvc.controller.ACommonController;
import com.abou.mvc.controller.ControllerUtils;

/**
 * The controller for the home page
 * 
 * @author khalid
 */

@Controller
@RequestMapping("/customer/home.do")
@SessionAttributes(ControllerUtils.SEARCH_REQUEST_ATT)
public class CustomerHomeController extends ACommonController {
  
  /**
   * The request mapping for home view
   */
  public static final String CUSTOMER_HOME_VIEW_REQUEST_MAPPING =
      "/customer/home.do";
  
  /**
   * The home view
   */
  public static final String CUSTOMER_HOME_VIEW = "customer/home";
  
  /**
   * The empty constructor
   */
  public CustomerHomeController() {

    super(CUSTOMER_HOME_VIEW, null);
  }
  
  /**
   * Shows the home page.
   * 
   * @param model The model
   * @return The search request
   */
  @RequestMapping(method = RequestMethod.GET)
  @ModelAttribute(ControllerUtils.SEARCH_REQUEST_ATT)
  public SearchProductsRequest show(ModelMap model) {

    SearchProductsRequest searchRequest = new SearchProductsRequest();
    model.put(ControllerUtils.SEARCH_REQUEST_ATT, searchRequest);
    
    return searchRequest;
  }
}
